import os
# progname='neith_fyluoding'
progname='honey_auto_packing'
saoma_port = 51236
saoma_ip = '192.168.1.150'
plc_ip = '192.168.1.23'
plc_port = 502

confdef = {
    # thd_conf 
    #'kakouok': ['thd_conf', 50, 0, 100, 'ok阈值'],
    #'kakoung': ['thd_conf', 60, 0, 100, 'ng阈值'],
    'saoma_match_wait': ['thd_conf', 20, 0, 100, '条码延迟匹配(0.1秒)'],
    'cap_sleep': ['thd_conf', 50, 0, 1000, '拍照延迟(0.01秒)'],

    # chk_conf
    'saoma_multi_match': ['chk_conf', 0, '条码多次匹配'],
    'lianxu_cap': ['chk_conf', 0, '连续拍照'],
    'stopline': ['chk_conf', 0, '开启开启检测停线'],
    'scadastopline': ['chk_conf', 0, '开启scada停线'],
    'use_scada': ['chk_conf', 0, '开启scada'],
    'plc_chufa': ['edit_conf', '62;52', 'plc触发方式'],
    'plc_chufacam': ['edit_conf', '52:1', 'plc触发相机方式'],
}


guize = [
    ['fy','fyluoding', '缺少风叶螺钉', 1],
    ['zj','zjluoding', '缺少支架螺钉', 2],
    ['cm','cmluoding', '缺少侧面螺钉', 2],
        ]

# 192.168.1.63 电控盒 账号admin 密码Aa12345678
camnames_ips = [
    '1.包装盒 0 192.168.0.112 baozhuanghe', # name， 是否旋转， ip (取第四个数字), 检测算法的名称
    '2.电池 0 192.168.1.34 dianchi',
    '3.数据线 0 rtsp://admin:Aa12345678:192.168.1.63 cap',
    '4.螺钉 0 192.168.1.34 zhuji',
    '5.说明书 0 rtsp://admin:Aa12345678:192.168.1.63 cap',
    '6.腕带 0 192.168.1.34 zhuji',
    '7.手机 0 rtsp://admin:Aa12345678:192.168.1.63 cap',
    '8.满盒 0 rtsp://admin:Aa12345678:192.168.1.63 cap',
    '9.标贴 0 rtsp://admin:Aa12345678:192.168.1.63 cap',

]

def jiaodu_trans(x):
    x = x.replace('逆', '-').replace('顺', '+')
    x = int(x)
    return x

camnames_ips = [s.split() for s in camnames_ips]
camnames = [s[0] for s in camnames_ips]
id2index = {}
for index, x in enumerate(camnames):
    id = x.split('.')[0]
    id2index[id] = index
cam_rot = [jiaodu_trans(s[1]) for s in camnames_ips]
cam_ips = [s[2] for s in camnames_ips]
quexians = [s[3] for s in camnames_ips]

config = {
    "captype": "hk",
    'password': '',
    "usbcamid": 1,
    "stopline_time": 15,
    'ips': cam_ips,
    'camnames': camnames,
    "ncams": 1,
    "oktext": "12345",
    "comid": "COM3",
    "saveimg": 1,
    "onlycapimg": 0, # 仅取图，不检测
    "use_pic_test": 1,
    "stopline": 1,  #1stop 0run
    "skip": 0,
    "myip":'10.177.104.98',
    'conf_thres': 0.4,
    'iou_thres': 0.1,
    'crop_num': 3,
    'imgsz': 512,
    'qutu_num': 8,
    'progname': progname,
    'cam_rot': cam_rot,
    'classname': '装配结构检验',
    'out_img_p': 'D:/data/save',
    'id':'0000',
    "errcode": "V4-NHJHL12"
}


pa = 'D:/data/220401小鸟/'
pa = 'D:/data/220401小鸟/220609/PO69051不良'
pa = 'D:/data/220401小鸟/220803不良品'
pa = 'E:/data/221015风轮间隙/2022-10-15'
pa = 'D:/data/2210301蜗壳卡扣/卡扣工位/卡扣图片（包含OK,NG）'
pa = 'D:/data/2210301蜗壳卡扣/卡扣工位/卡扣ng图片'
pa = 'D:/data/221101螺钉有无/ptc螺钉/20221108'
pa = 'D:/data/221101螺钉有无/nei1_luoding2PTC'
pa = 'D:/data/221101螺钉有无/内二PTC螺钉-ok'
pa = r'D:\data\230713天花线\test\0715\保压 （无红点图片）'

pa = pa if os.path.exists(pa) else 'E:/data/221101螺钉有无/nei1_luoding2PTC'
pa = pa if os.path.exists(pa) else 'D:/data/xiaoniao'
pa = pa if os.path.exists(pa) else 'E:/OK/camera3/2022-10-17/511223963132A170310138'
pp = [
    f'{pa}/变形',
    f'{pa}/毛丝6',
]
pp = [
    f'{pa}/变形',
    f'{pa}/变形',
]
pp = {
    '34':r'D:\data\230713天花线\test\0715\风叶螺母 (L02489832)',

    '112':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '110':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '113':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',

    '111':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '115':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '116':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',

    '117':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '119':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '222':r'D:\data\231207huoni\trainseg_zhihe\imglabs_yolov5\images\val',
    '118':r'D:\data\231207huoni\trainV8Seg_full_box\add_imgs\20240117', # 满盒检测

}
global_dict_param = {'step8': {'height':100}}
